﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using Cubicle.Core.Config;
using Cubicle.Core.Processors;

namespace Cubicle.Excel.Binding
{
    [Export]
    [PartCreationPolicy(CreationPolicy.Shared)]
    public class BindManager : Invoker
    {

        public static string ProcessorKey = "Binding";

        static BindManager()
        {
            Bindings = new Dictionary<int, BindingElement>();
        }

        public static Dictionary<int, BindingElement> Bindings { get; private set; }

        // Return types allowed by ExcelDNA
        public static Type[] AllowableReturnTypes = new[]
            {
                typeof(double), typeof(double[]), typeof(double[,]), typeof(string), 
                typeof(object), typeof(object[]), typeof(object[,]), typeof(DateTime), 
                typeof(bool), typeof(int), typeof(Int16), typeof(UInt16), typeof(Decimal)
            };

        [ImportingConstructor]
        public BindManager(CompositionContainer container, EngineConfig config) : base(container, config, ProcessorKey) { }

    }
}